package com.system.controller.admin;

import com.common.annotation.LogInfo;
import com.core.system.domain.Resource;
import com.system.service.ResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/resource")
@Api(value = "后台资源控制层",tags = {"后台资源控制层"})
@LogInfo
public class ResourceExController {

    @Autowired
    private ResourceService resourceService;

    @ApiOperation("刷新整个资源树接口")
    @PostMapping("/saveJson")
    @PreAuthorize("hasAnyAuthority(@servletUtils.getUrl)")
    public ResponseEntity save(@RequestBody String jsonStr){ return resourceService.saveJson(jsonStr);}


    @ApiOperation("加载资源树接口")
    @GetMapping("/tree")
    @PreAuthorize("hasAnyAuthority(@servletUtils.getUrl)")
    public ResponseEntity loadTree(Resource resource) {
        return resourceService.loadTree(resource);
    }

}
